home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / LgcyPlus / disk2 / LISSAJOU._ / LISSAJOU.
Encoding:
Text File  |  2001-03-02  |  2.4 KB  |  65 lines

  1. 10    ! ***************************************************************
  2. 20    ! Example: Lissajous Patterns
  3. 30    !
  4. 40    ! This example plots one sine wave vs. another. The phase
  5. 50    ! and ratio of frequencies are varied. The resulting curves
  6. 60    ! are Lissajous curves.
  7. 70    !
  8. 80    ! ***************************************************************
  9. 90    !
  10. 100   ! Set up an XY display for the curves
  11. 110   ! Most of the attributes are programmed outside the loop
  12. 120   !
  13. 130   ASSIGN @Lissajous TO WIDGET "XY GRAPH";SET ("TITLE":" Example: Lissajous Patterns","TRACE COUNT":1,"POINT CAPACITY":512,"HEIGHT":250,"WIDTH":250,"X":100,"Y":100)
  14. 140   CONTROL @Lissajous;SET ("TRACE BACKGROUND":9,"TRACE PEN":0)
  15. 150   CONTROL @Lissajous;SET ("SYSTEM MENU":"Quit")
  16. 160   ON EVENT @Lissajous,"SYSTEM MENU" GOTO Finis
  17. 170   !
  18. 180   ! Set the limits in the graph to -1 to +1 for both axes
  19. 190   !
  20. 200   CONTROL @Lissajous;SET ("CURRENT AXIS":"X","ORIGIN":-1,"RANGE":2,"SHOW NUMBERING":0,"SHOW TICKS":0)
  21. 210   CONTROL @Lissajous;SET ("CURRENT AXIS":"Y","ORIGIN":-1,"RANGE":2,"SHOW NUMBERING":0,"SHOW TICKS":0)
  22. 220   !
  23. 230   ! Two string displays which show the current values of the loop veriables
  24. 240   !
  25. 250   ASSIGN @Show_phase TO WIDGET "STRING";SET ("TITLE":"  Phase","X":50,"Y":10)
  26. 260   ASSIGN @Show_ratio TO WIDGET "STRING";SET ("TITLE":"  Ratio","X":250,"Y":10)
  27. 270   !
  28. 280   ! Calculate the reference sine wave and set the X data to it
  29. 290   !
  30. 300   INTEGER I,N
  31. 310   N=50
  32. 320   ALLOCATE F1(N),F2(N)
  33. 330   ALLOCATE Fbig(0:N*2)
  34. 340   FOR I=0 TO N
  35. 350     F1(I)=SIN(I*2*PI/N)
  36. 360   NEXT I
  37. 370   CONTROL @Lissajous;SET ("X DATA":F1(*))
  38. 380   !
  39. 390   ! The Ratio variable is used the vary the ratio of the frequencies
  40. 400   ! of the two sine waves
  41. 410   !
  42. 420   LOOP
  43. 430     FOR Ratio=1 TO 5
  44. 440       Tmp1=(2*PI/N)*Ratio
  45. 450       FOR I=0 TO N*2
  46. 460         Fbig(I)=SIN(I*Tmp1)
  47. 470       NEXT I
  48. 480       CONTROL @Show_ratio;SET ("VALUE":VAL$(Ratio))
  49. 490   !
  50. 500   ! This loop offsets the phase of the second sine wave
  51. 510   !
  52. 520       FOR Phase=0 TO N-1
  53. 530         CONTROL @Show_phase;SET ("VALUE":VAL$(Phase))
  54. 540         Start=Phase/360*N
  55. 550         Start=Phase
  56. 560         MAT F2=Fbig(Start:Start+N)
  57. 570         CONTROL @Lissajous;SET ("Y DATA":F2(*))
  58. 580         WAIT .1
  59. 590       NEXT Phase
  60. 600     NEXT Ratio
  61. 610   END LOOP
  62. 620 Finis:   !
  63. 630   ASSIGN @Lissajous TO *         ! Delete XY GRAPH widget
  64. 640   END
  65.